/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

import request from "@/router/axios";

export function fetchList(query) {
  return request({
    url: "/contract/ctcontract/page",
    method: "get",
    params: query
  });
}

export function addObj(obj) {
  return request({
    url: "/contract/ctcontract/save",
    method: "post",
    data: obj,
    // headers: {
    //   "Content-Type": "multipart/form-data; charset=utf-8"
    // }
  });
}

export function getObj(id) {
  return request({
    url: "/contract/ctcontract/" + id,
    method: "get"
  });
}

export function delObj(id) {
  return request({
    url: "/contract/ctcontract/" + id,
    method: "delete"
  });
}

export function putObj(obj) {
  return request({
    url: "/contract/ctcontract",
    method: "put",
    data: obj,
    headers: {
      "Content-Type": "multipart/form-data; charset=utf-8"
    }
  });
}

//获取公司名称
export function getCompanyList(query) {
  return request({
    url: "/config/syscompany/page",
    method: "get",
    params: query
  });
}

//获取房产信息数据
export function getProjectList(query) {
  return request({
    url: "/estate/rmproject/page",
    method: "get",
    params: query
  });
}

//获取选择的单价 chargeType 1.市场管理服务费 2.租金
export function getChargeUnitpPriceList(query) {
  return request({
    url: "/config/syschargeunitprice/page",
    method: "get",
    params: query
  });
}

//获取合同税率
export function getContractTaxRateList(query) {
  return request({
    url: "/config/syscontracttaxrate/page",
    method: "get",
    params: query
  });
}

//获取合同类型
export function getContractType(query) {
  return request({
    url: "/config/syscontracttype/page",
    method: "get",
    params: query
  });
}

//获取合同操作日志
export function getOperationLog(id) {
  return request({
    url: "/config/sysoperationlog/" + id + "/3", //1.房产 2.车辆 3.合同
    method: "get"
  });
}

//获取附件数据fileType 文件类型
export function getFileList() {
  var query = {
    current: 1,
    size: 20,
    fileType: 3
  };
  return request({
    url: "/config/sysuploadfile/page",
    method: "get",
    params: query
  });
}

//上传文件
export function uploadFile(obj) {
  console.log(obj);
  return request({
    url: "/config/sysuploadfile/upload",
    method: "post",
    data: obj
  });
}

//下载附件
export function downFile(id) {
  return request({
    url: "/config/sysuploadfile/download/" + id,
    method: "get",
    responseType: "arraybuffer",
    downloadFlag: true
  });
}

//删除附件
export function deleteFile(id) {
  return request({
    url: "/config/sysuploadfile/" + id,
    method: "delete"
  });
}

//合同签订/续签/终止/退保证金
export function putModifyObj(obj) {
  return request({
    url: "/contract/ctcontract/update/status",
    method: "post",
    data: obj
  });
}

export function getCompanyByPhone(obj) {
  return request({
    url: "/config/syscompany/getCompanyByPhone",
    method: "get",
    params: obj
  });
}
// 通过公司ID获取公司信息
export function syscompanyid(obj, id) {
  return request({
    url: "/config/syscompany/" + id,
    method: "get",
    params: obj
  });
}

export function selectType(obj, id, type) {
  return request({
    url: "/estate/rmproject/get/select/" + id + "/" + type,
    method: "get",
    params: obj
  });
}
export function calculation(obj) {
  return request({
    url: "/contract/ctcontract/calculation",
    method: "post",
    data: obj
  });
}

export function rmEexport(obj) {
  return request({
    url: "/contract/ctcontract/export",
    method: "get",
    params: obj,
    responseType: "blob"
  });
}

export function fileLists(id) {
  return request({
    url: "/contract/ctcontract/file/list/" + id,
    method: "get",
    params: {}
  });
}

// 退费
export function refund(obj) {
  return request({
    url: "/contract/ctcontract/refund",
    method: "post",
    data: obj
  });
}
// 续签
export function relet(obj) {
  return request({
    url: "/contract/ctcontract/relet",
    method: "post",
    data: obj
  });
}
// id 查费用
export function gesummary(obj) {
  return request({
    url: "/contract/ctcontractchargesummary/" + obj,
    method: "get",
    params: {}
  });
}
// 更新合同单价
export function updatePrice(obj) {
  return request({
    url: "/contract/ctcontract/update",
    method: "post",
    data: obj
  });
}
// 导入
export function ImportFile(data) {
  return request({
    url: "/contract/ctcontract/import",
    method: "post",
    data: data
  });
}
//查找已销售合同的房屋编号
export function getRentNumber(){
  return request({
    url: "/contract/remote/ctContractProject/rt/getRentNumber",
    method: "get",
  });
}
//通过房屋编号查询房屋信息
export function findReProjectByNum(data){
  return request({
    url: "/estate/remote/rmProject/rt/findReProjectByNum",
    method: "post",
    data: data
  });
}

//通过合同编号查询合同信息
export function findCtContractByContractNumber(data){
  return request({
    url: "/contract/remote/ctContract/rt/findCtContractByContractNumber",
    method: "get",
    data: data
  });
}
